package android.slc.extras.component.tree.ui

import android.app.Application
import android.os.Bundle
import android.slc.appbase.vm.AppBaseViewModel
import android.slc.extras.component.tree.entity.SlcTree
import android.slc.extras.component.tree.entity.SlcTreeNav
import androidx.databinding.ObservableField

/**
 *
 * @Description:
 * @Author: sunlunchang
 * @CreateDate: 2021/12/06 下午 2:52
 *
 */
abstract class TreeListBrowseVm<T : SlcTree>(application: Application) :
    AppBaseViewModel(application) {

    val dataListVmBox: TreeListVmBox<T> by lazy {
        createDataListVmBox()
    }

    val slcTreeNavOf = ObservableField<SlcTreeNav>()

    fun initVm(bundle: Bundle) {
        registerVmBox(dataListVmBox)
        dataListVmBox.initVmBox(bundle)
        dataListVmBox.refresh()
        this.slcTreeNavOf.set(
            SlcTreeNav().apply {
                this.treeName = this@TreeListBrowseVm.dataListVmBox.treeName
            })
    }

    protected abstract fun createDataListVmBox(): TreeListVmBox<T>

}